package com.educate.config;

import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yjj
 * @date 2021/11/22
 * @description: 阿里云oss的配置类
 */
@Configuration
public class AliyunOSSConfig {

    /** 从配置文件中读取endPoint */
    @Value("${aliyun.oss.file.endpoint}")
    private String ossEndpoint;
    /** 从配置文件中读取KeyId */
    @Value("${aliyun.oss.file.keyid}")
    private String keyId;
    /** 从配置文件中读取KeySecret */
    @Value("${aliyun.oss.file.keysecret}")
    private String keySecret;

    @Bean
    public OSSClient ossClient(){
        return (OSSClient) new OSSClientBuilder().build(ossEndpoint, keyId, keySecret);

    }
}
